<template>
  <div
    class="van-coupon van-cell art"
    role="button"
    tabindex="0"
    style="width: auto"
    @click="toArticleDetail"
  >
    <div
      class="
        van-cell__value van-cell__value--alone
        van-contact-card__value
        definContent
      "
    >
      <div class="car_title">
        {{ article.title }}
      </div>
      <div class="ell_1">{{ article.introduction }}</div>
      <div>
        <div class="updateAt">
          {{ article.updateAt }}
        </div>
      </div>
    </div>
    <div class="van-image" style="width: 130px">
      <img
        :src="article.imgUrl"
        class="van-image__img"
        style="object-fit: cover"
      />
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'

const router = useRouter()

interface Props {
  article: {
    id: string | number
    title: string
    introduction: string
    updateAt: string
    imgUrl: string
    [attr: string]: any
  }
  item: any
}

const props = defineProps<Props>()

const toArticleDetail = () => {
  const id = props.article.id
  const name = props.item.name
  router.push({
    name: 'ArticleDetail',
    params: { id, name },
  })
}
</script>

<style lang="less" scoped>
.art img {
  border-radius: 5px;
}

.car_title {
  font-size: 13px;
  font-weight: bold;
}

.definContent {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  min-height: 115px;
  padding-right: 8px;

  .ell_1 {
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    word-break: break-all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    text-align: left;
  }
}

.updateAt {
  display: inline-block;
  color: #828282;
  font-size: 12px;
}
</style>
